
#ifndef __WD_THREADPOOL_H__
#define __WD_THREADPOOL_H__

#include "tcp.h"
#include "mkdir.h"
#include "ls.h"
#include "rm.h"
#include "password.h"

#include "transferfile.h"
#include "mysql_op.h"
#include "hashMap_char.h"
#include "hashMap_int.h"
#include "getid.h"

typedef struct userid_t
{
	int peerfd;
	int userid;
	struct userid_t *next;
} useridHash, *puseridHash;

typedef struct
{
	puseridHash front;
	puseridHash rear;
	pthread_mutex_t mutex;
} useridQue;

typedef struct thread_pool_s
{
	pthread_t *threads;
	int threadNumber;
	task_queue_t queue;
	fileQue fileque;
	HashMap_int* userPeerfdHash;
	int epfd;
	HashMap* Md5hashmap;
} thread_pool_t, *pThread_pool_t;


void *threadFunc(void *);

void threadpoolInit(thread_pool_t *, int, int);
void threadpoolDestroy(thread_pool_t *);
void threadpoolStart(thread_pool_t *pthreadpool);

void GetFile(int peerfd,char* data,pThread_pool_t p);
void PushFile(int peerfd,char* filename,pThread_pool_t p);

#endif
